package com.f.manage.并发;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ConcurrentHashMapTest {

    public static void main(String[] args) {
        ConcurrentHashMap<String,String> hm = new ConcurrentHashMap<>();
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 25; i++) {
                hm.put(i + "", i + "" );
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 25; i < 51; i++){
                hm.put(i + "",i+ "");
            }
        });
        t1.start();
        t2.start() ;
// 让两个线程有机会将数据添加完毕Thread.sleep(1000);
        for (int i = 0; i < 51; i++) {
            System.out.println(hm.get(i + ""));
            System.out.println(1);
        }
    }
}
